/******************************************************************************
** $Id: dc_time_api.h,v 1.1.1.1 2009-02-13 22:36:43 beliloi Exp $
**                 Proprietary and Confidential Information                  **
**                                                                           **
**                 Copyright (c) SigmaTel, Inc. Unpublished                  **
**                                                                           **
** This source code and the algorithms implemented therein constitute        **
** confidential information and may compromise trade secrets of SigmaTel,    **
** Inc. or its associates, and any unauthorized use thereof is prohibited.   **
**                                                                           **
******************************************************************************/
#ifndef _dc_time_h_
# define _dc_time_h_
/**************************************************************************//**
*  @file dc_time.h
*
*  @brief This file contains the API for time. Please refer to the Operating
*  Environment reference manual for details.
******************************************************************************/
/******************************************************************************
*  FILE FORMAT: <PUBLIC>
*      1. INCLUDES 
*      2. ENUMERATIONS 
*      3. DEFINES
*      4. STRUCTURES
*      5. GLOBALS
*      6. PUBLIC FUNCTION PROTOTYPES
******************************************************************************/
/******************************************************************************
*  1. INCLUDES
******************************************************************************/
/******************************************************************************
*  2. ENUMERATIONS
******************************************************************************/
/******************************************************************************
*  3. DEFINES
******************************************************************************/
/******************************************************************************
*  4. STRUCTURES
******************************************************************************/

/** @brief This structure is used to support microsecond time accuracy. */
typedef struct utime 
{
    /** System timer tick value */
    UINT32 tick;
    
    /** Timer count value, as read from DigiColor SOC timer */
    INT32 tval;
} UTIME;
/******************************************************************************
*  5. GLOBALS
******************************************************************************/
/******************************************************************************
*  6. PUBLIC FUNCTION PROTOTYPES
******************************************************************************/
DC_RETURN_CODE dc_time_init(UINT32 sys_period_usec,
                            UINT32 main_clock_hz);
DC_RETURN_CODE dc_time_ticks_from_usec(UINT32 *system_ticks,
                                       UINT32 usec);
DC_RETURN_CODE dc_utime_get_from_tick(UINT32 *usec);
void dc_time_wait_cycles(UINT16 cycles);
UINT32 dc_time_elapsed_msec(ULONG t0, ULONG t1);
UINT32 dc_time_elapsed_sec(ULONG t0, ULONG t1);
UINT32 dc_utime_elapsed_usec(UTIME *t0, UTIME *t1);
UINT32 dc_time_diff_msec(ULONG t0);
UINT32 dc_time_diff_sec(ULONG t0);
UINT32 dc_utime_diff_usec(UTIME *t0);
void dc_utime_get(UTIME *ut);
#endif /*  _dc_time_h_ */
